package com.neusoft.service;

import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.neusoft.bean.AdminInfoBean;
import com.neusoft.db.DBProvider;
import com.neusoft.myutils.MyUtil;

public class AdminInfoService {
//	public List<AdminInfoBean> doAdminLogined(String adminName,String adminPsw){
//	List<AdminInfoBean> adminLst = null;
//	String sql = "select * from admininfo where adminname =? and adminpsw=?";
//	adminLst = DBFactory.getDBProviderInstance().query(
//			sql, new BeanListHandler<>(AdminInfoBean.class), adminName,adminPsw);
//	return adminLst;
//	
//}
	
	public List<AdminInfoBean> doAdminLogined(AdminInfoBean aib){
		//优化将adminInfoBean作为载体传值
		List<AdminInfoBean> adminLst = null;
		String sql = "select * from admininfo where adminname =? and adminpsw=?";
//		adminLst = DBFactory.getDBProviderInstance().query(
//				sql, new BeanListHandler<>(AdminInfoBean.class), aib.getAdminName(),aib.getAdminPsw());
		//优化调用工具类通过泛型和反射获取类的方法获取DBProvider实例对象
		adminLst = MyUtil.getInstance(DBProvider.class).query(
				sql, new BeanListHandler<>(AdminInfoBean.class), aib.getAdminName(),aib.getAdminPsw());
		return adminLst;
		
	}
}
